/**
 * 
 */
package gameEngine;

import java.awt.Color;
import java.util.HashMap;
import java.util.Observable;

/**
 * @author joseph
 *
 */
public class Player extends Observable {
	private String name;
	private int id;
	private int nbPieces;
	//private int leftSubPieces;
	private HashMap<Integer, Integer> leftPieces;
	private PiecesList piecesList;
	
	public Player(int id){
		super();
		setPiecesList(new PiecesList(this));
		setId(id);
	}
	

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
		setChanged();
		notifyObservers();
	}


	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}


	/**
	 * @param nbPieces the nbPieces to set
	 */
	public void setNbPieces(int nbPieces) {
		this.nbPieces = nbPieces;
		setChanged();
		notifyObservers();
	}

	/**
	 * @return the nbPieces
	 */
	public int getNbPieces() {
		return nbPieces;
	}


	/**
	 * @param leftPieces the leftPieces to set
	 */
	public void setLeftPieces(HashMap<Integer, Integer> leftPieces) {
		this.leftPieces = leftPieces;
		setChanged();
		notifyObservers();
	}


	/**
	 * @return the leftPieces
	 */
	public HashMap<Integer, Integer> getLeftPieces() {
		return leftPieces;
	}


	/**
	 * @param piecesList the piecesList to set
	 */
	private void setPiecesList(PiecesList piecesList) {
		this.piecesList = piecesList;
	}


	/**
	 * @return the piecesList
	 */
	public PiecesList getPiecesList() {
		return piecesList;
	}


	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}


	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}


	/**
	 * @return the color
	 */
	public Color getColor() {
		return getColorFromId(id);
	}
	
	static public Color getColorFromId(int id) {
		switch(id) {
		case 1: return Color.blue;
		case 2: return Color.yellow;
		case 3: return Color.red;
		case 4: return Color.green;
		default: return Color.black;
		}
	}
}
